package cj.web.marriageSC.dao;
/*
 *  
 *  
*/
import java.util.List;
import java.util.Map;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.marriageSC.domain.SCOrder;

/**
 * 
 * @author 
 *
 */
@DAO
public interface SCOrderDAO{
    @SQL("select * from SCOrder where id=:1")
    SCOrder queryById(int id);
    
	@SQL("UPDATE SCOrder SET expressBill=:t.expressBill,expressCom=:t.expressCom,status=:t.status,updateAt=NOW(),updateUser=:t.updateUser WHERE id=:t.id")
    void update(@SQLParam("t") SCOrder sCOrder);

	@SQL("UPDATE SCOrder SET status=:2 WHERE id=:1")
	void setStatus(int id, int status);

	@SQL("select * from (select * from SCOrder where deleteFlag=1 #if(:t.memo!=null){ AND memo LIKE '%##(:t.memo)%' } #if(:t.receiverPhone!=null){ AND receiverPhone LIKE '%##(:t.receiverPhone)%' } #if(:t.receiverName!=null){ AND receiverName LIKE '%##(:t.receiverName)%' }  #if(:t.orderNo!=null){ AND orderNo LIKE '%##(:t.orderNo)%' } and status>1 #if(:t.status!=-1){ and status = :t.status} #if(:t.sellerId!=-1){ and sellerId = :t.sellerId} #if(:t.createAt!=''){ AND createAt BETWEEN :t.createAt AND :t.updateAt } order by status,createAt desc ) as table1 UNION select * from (select * from SCOrder where deleteFlag=1 #if(:t.memo!=null){ AND memo LIKE '%##(:t.memo)%' } #if(:t.receiverPhone!=null){ AND receiverPhone LIKE '%##(:t.receiverPhone)%' } #if(:t.receiverName!=null){ AND receiverName LIKE '%##(:t.receiverName)%' }  #if(:t.orderNo!=null){ AND orderNo LIKE '%##(:t.orderNo)%' } and status<=1 #if(:t.status!=-1){ and status = :t.status} #if(:t.sellerId!=-1){ and sellerId = :t.sellerId} #if(:t.createAt!=''){ AND createAt BETWEEN :t.createAt AND :t.updateAt } order by status desc,createAt desc ) as table2 order by orderNo desc limit :t.start,:t.length")
	List<SCOrder> queryBySellerId(@SQLParam("t")SCOrder order);

	@SQL("select count(0) from SCOrder where deleteFlag=1 #if(:t.memo!=null){ AND memo LIKE '%##(:t.memo)%' } #if(:t.receiverPhone!=null){ AND receiverPhone LIKE '%##(:t.receiverPhone)%' } #if(:t.receiverName!=null){ AND receiverName LIKE '%##(:t.receiverName)%' }  #if(:t.orderNo!=null){ AND orderNo LIKE '%##(:t.orderNo)%' } #if(:t.status!=-1){ and status = :t.status} #if(:t.sellerId!=-1){ and sellerId = :t.sellerId} #if(:t.createAt!=''){ AND createAt BETWEEN :t.createAt AND :t.updateAt }")
	int sizeBySellerId(@SQLParam("t")SCOrder order);

	@SQL("UPDATE SCOrder SET expressBill=:t.expressBill,expressCom=:t.expressCom,updateAt=NOW(),updateUser=:t.updateUser WHERE id=:t.id")
	void chgXprBill(@SQLParam("t")SCOrder order);

	@SQL("UPDATE SCOrder SET deleteFlag=0,updateAt=NOW(),updateUser=:t.updateUser WHERE id=:t.id")
	void delete(@SQLParam("t")SCOrder order);

	@SQL("select orderNo,sellerName,discntPrice,receiverName,receiverPhone,receiverAddress,isInvoice,invoiceHead,memo,expressCom,expressBill,status,wxTradeNo,createAt from SCOrder where deleteFlag=1 and status<>0 #if(:t.memo!=''){ AND memo LIKE '%##(:t.memo)%' } #if(:t.receiverPhone!=''){ AND receiverPhone LIKE '%##(:t.receiverPhone)%' } #if(:t.receiverName!=''){ AND receiverName LIKE '%##(:t.receiverName)%' }  #if(:t.orderNo!=''){ AND orderNo LIKE '%##(:t.orderNo)%' } #if(:t.status!=-1){ and status = :t.status} #if(:t.sellerId!=-1){ and sellerId = :t.sellerId} #if(:t.createAt!=''){ AND createAt BETWEEN :t.createAt AND :t.updateAt } order by status desc,createAt desc")
	List<Map> outputBySellerId(@SQLParam("t")SCOrder order);

	@SQL("UPDATE SCOrder SET status=:2 WHERE id in (##(:1))")
	void mutiSetStatus(List<Integer> ids, int value);
    
}